package com.itjob.scott.servlet;

import java.io.IOException;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class LoginServlet implements Servlet {


	public void destroy() {
		
		System.out.println("destroy销毁....");
		

	}

	public ServletConfig getServletConfig() {
		return null;
	}

	public String getServletInfo() {
		return null;
	}

	public void init(ServletConfig config) throws ServletException {
		System.out.println("init初始化....");

	}

	public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
		System.out.println("service开始服务....");
		String username = request.getParameter("username");
		
		//向下个页面传值
		request.setAttribute("username", username);
		//request.getAttribute("username");
		System.out.println(username);
		
		//服务完成后给个提示页面
		
		//跳转到welcome.jsp
		
		
		//内部跳转  不需要让浏览器知道 直接用 request就行
		//RequestDispatcher dispatcher = request.getRequestDispatcher("welcome.jsp");
		
		//把参数继续往下传
		//dispatcher.forward(request, response);
		request.getRequestDispatcher("welcome.jsp").forward(request, response);

	}

}
